package cn.com.nes.site.module.service.monitor;

import java.sql.Connection;
import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.dao.monitor.DeviceDaoImpl;

@Service
public class DeviceService {

	@Resource
	private DeviceDaoImpl impl;

	public PageData getEquipmentCount(DataReq req) {
        return impl.getEquipmentCount(req);
    }

    public PageData getEquipment(DataReq req) {
        return impl.getEquipment(req);
    }
	
	public PageData getStation(DataReq req) {
        return impl.getStation(req);
    }
	
	public PageData getRepairPeople(DataReq req) {
        return impl.getRepairPeople(req);
    }
	public PageData delEquipmentById(DataReq req) {
        return impl.delEquipmentById(req);
    }
	public PageData getParamGroup(DataReq req) {
        return impl.getParamGroup(req);
    }
	
	public PageData unbindEquipmentById(DataReq req) {
        return impl.unbindEquipmentById(req);
    }
	
	public PageData getWorkOrder(DataReq req) {
        return impl.getWorkOrder(req);
    }
	
	public PageData getCardInfo(DataReq req) {
        return impl.getCardInfo(req);
    }
	public PageData getEquipmentInfoOperationCondition(DataReq req) {
		return impl.getEquipmentInfoOperationCondition(req);
	}
	public PageData addCustomField(DataReq req) {
		return impl.addCustomField(req);
	}
	public PageData saveDataItemGroups(DataReq req) {
		return impl.saveDataItemGroups(req);
	}
	public PageData getEquipmentInfoOperationConditionHistory(DataReq req) throws SQLException {
		PageData res = new PageData();
		Connection conn = null;
		Connection conn_click = null;
		try {
			conn = DBUtils.getDBConn_Ope();
			conn_click = DBUtils.getJNDIclikchouse() ;
			res = impl.getEquipmentInfoOperationConditionHistory(conn,conn_click,req);
			conn.commit();
		} catch (Exception e) {
			e.printStackTrace();
			conn.rollback();
		} finally {
			if (conn != null)
				conn.close();
			if (conn_click != null)
				conn_click.close();
		}
		return res;
	}
	
	public PageData getRealFaultList(DataReq req) {
        return impl.getRealFaultList(req);
    }
	
	public PageData getHisFaultList(DataReq req) {
        return impl.getHisFaultList(req);
    }
	
	public PageData getRealWarns(DataReq req) {
        return impl.getRealWarns(req);
    }
	
	public PageData getHisWarns(DataReq req) {
        return impl.getHisWarns(req);
    }

	public PageData getEquipmentImages(DataReq req) {
		return impl.getEquipmentImages(req);
	}

	public PageData checkDeviceWorkingState(DataReq req) throws Exception {
		return impl.checkDeviceWorkingState(req);
	}

	public PageData sendControlCommand(DataReq req) throws Exception {
		return impl.sendControlCommand(req);
	}

	public PageData getControlLog(DataReq req) throws Exception {
		return impl.getControlLog(req);
	}

	public PageData editEquipmentInfo(DataReq req) throws Exception {
		return impl.editEquipmentInfo(req);
	}
	
	
	public PageData updateEquipment(DataReq req) throws SQLException {
		return impl.updateEquipment(req);
	}
	
	public PageData deleteEquipment(DataReq req) throws SQLException {
		return impl.deleteEquipment(req);
	}
	
	public PageData equipmentUntying(DataReq req) throws SQLException {
		return impl.equipmentUntying((String) req.getReqData().get("sbId"));
	}
	
	public int verifyUntyingSecret(String secret, DataReq req) {
		return impl.verifyUntyingSecret(secret, req);
	}
	public PageData unbindEquipment(DataReq req) throws Exception {
		return impl.unbindEquipment(req);
	}

}
